package com.chanyachting.emall.domain;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.chanyachting.emall.dao.ProductimageDAO;
import com.chanyachting.emall.domain.base.BaseProductimage;

/**
 * This is the object class that relates to the productimage table.
 * Any customizations belong here.
 */
public class Productimage extends BaseProductimage {

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Productimage () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Productimage (java.lang.Integer _id) {
		super(_id);
		
		Productimage pi=(Productimage)new ProductimageDAO().load(Productimage.class, _id);
		
		if(pi!=null){
			
			try {
				BeanUtils.copyProperties(this, pi);
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (InvocationTargetException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

	/**
	 * Constructor for required fields
	 */
	public Productimage (
		java.lang.Integer _id,
		java.lang.Integer _productId,
		java.lang.String _isdefaul,
		java.lang.String _imgUrl) {

		super (
			_id,
			_productId,
			_isdefaul,
			_imgUrl);
	}
/*[CONSTRUCTOR MARKER END]*/
	
	
	public static List<Productimage> listByProductId(int pid){
		
		String args []={String.valueOf(pid)};
		
		return new ProductimageDAO().find("from Productimage where productId=?",args);
	}
	
	public boolean save(){
		
		new ProductimageDAO().save(this);
		
		return true;
	}
	
	public boolean update(){
		
		new ProductimageDAO().update(this);
		
		return true;
	}
	
	public boolean delete(){
		
		new ProductimageDAO().delete(this);
		
		return true;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}